找传奇、传世资源到传世资源站!

C# 放大镜 示例源码(图片放大)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboardusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MagPanelTest
{
    public partial class PartialMagPicPanel : UserControl
    {
        public PartialMagPicPanel()
        {
            InitializeComponent();
        }

        private void PartialMagPicPanel_Load(object sender, EventArgs e)
        {
            IntPtr dc;
            IntPtr region;
            IntPtr hpen2;
            IntPtr holdpen;
            dc = GetDC(this.Handle);
            BeginPath(dc);
            hpen2 = CreatePen(5, 5, ColorTranslator.ToWin32(Color.Red));
            holdpen = (IntPtr)SelectObject(dc, hpen2);
            Ellipse(dc, 0, 0, this.Width, this.Height);
            DeleteObject(hpen2);
            EndPath(dc);
            region = PathToRegion(dc);
            SetWindowRgn(this.Handle, region, true);
        }

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr BeginPath(IntPtr hdc);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern int SetBkMode(IntPtr hdc,int nBkMode);
        const int TRANSPARENT = 1;

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr EndPath(IntPtr hdc);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr PathToRegion(IntPtr hdc);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr CreatePen(int fnPenStyle,int nWidth,int COLORREF);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        public static extern IntPtr CreateSolidBrush(Int32 crColor);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr SelectObject(IntPtr hdc, IntPtr hpen);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern IntPtr DeleteObject(IntPtr hpen);

        [System.Runtime.InteropServices.DllImport("gdi32")]
        private static extern int Ellipse(IntPtr hdc, int X1, int Y1, int X2, int Y2);

        [System.Runtime.InteropServices.DllImport("user32")]
        private static extern int SetWindowRgn(IntPtr hwnd, IntPtr hRgn, bool bReDraw);

        [System.Runtime.InteropServices.DllImport("user32")]
        private static extern IntPtr GetDC(IntPtr hwnd);

        [System.Runtime.InteropServices.DllImport("gdi32")]

        static extern int SetROP2(System.IntPtr hdc, int rop);

        [System.Runtime.InteropServices.DllImport("gdi32")]

        static extern int MoveToEx(IntPtr hdc, int x, int y, IntPtr lppoint);

        [System.Runtime.InteropServices.DllImport("gdi32")]

        static extern int LineTo(IntPtr hdc, int X, int Y);
    }
}

放大镜

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复